package Platform.WandaProject;

import Base.DataFactory;
import Base.TestBase;
import org.testng.Assert;

/**
 * Created by Alain on 2016/3/9.
 */
@SuppressWarnings("unused")
public class Project extends TestBase {
    private static TestBase TB = new TestBase();
    private static DataFactory DF = new DataFactory();
    private static String requestURL=null, response=null, requestBody=null,
            projectVersionId    =   DF.getCellValue("WandaProject", "projectVersionId"),
            projectId           =   DF.getCellValue("WandaProject", "projectId"),
            type                =   DF.getCellValue("WandaProject", "type");

    /*01.获取项目列表
    GET  https://bim.wanda.cn/platform/project
    参数名         是否必选      类型        描述
    type	        是	         long	     类型，1.标准模型，2.族库，3.项目
    projectType 	否	         string	     项目类型，1:综合体; 2:文化旅游; 3:境外; 4:其他
    name	        否	         string	     项目名称
    estateType	    否	         string	     物业类型，1:轻资产;2:重资产
    province        否	         string	     项目地点
    region	        否	         string	     管理分区
    complete	    否	         boolean	 是否完成，true/false
    open	        否	         boolean	 是否开业，true/false
    openTimeStart	否	         date	     起始开业时间，yyyy-MM-dd
    openTimeEnd	    否	         date	     结束开业时间，yyyy-MM-dd
    pageIndex	    否	         string	     当前页,默认为第1页
    pageItemCount	否	         string	     每页显示数量，默认或最大为100条。*/
    public String getProjectList(){
        requestURL = "/platform/project?type="+type;

        //send request
        try {
            response = TB.apiResponse(requestURL, "GET");
        } catch (Exception e){
            Assert.fail("");
        }
        return response;
    }

    /*02.获取分组项目列表
    GET  https://bim.wanda.cn/platform/project/groupByProvince
    参数名         是否必选      类型        描述
    */
    public String getProjectByProvince(){
        requestURL = "/platform/project/groupByProvince";

        //send request
        try {
            response = TB.apiResponse(requestURL, "GET");
        } catch (Exception e){
            Assert.fail("");
        }
        return response;
    }

    /*03.获取项目版本列表
    GET  https://bim.wanda.cn/platform/project/{projectId}/version
    参数名         是否必选      类型        描述
    projectId   	是	         long	     项目ID*/
    public String getProjectVersionList(){
        //initial parameters
        requestURL = "/platform/project/"+projectId+"/version";

        //send request
        try {
            response = TB.apiResponse(requestURL, "GET");
        } catch (Exception e){
            Assert.fail("");
        }
        return response;
    }

    /*04.获取项目版本信息
    GET  https://bim.wanda.cn/platform/project/{projectId}/version/{projectVersionId}
    参数名            是否必选       类型        描述
    projectId        	是	         long        项目ID
    projectVersionId	是	         long	     项目版本ID*/
    public String getProjectVersionInfo(){
        //initial parameters
        requestURL = "/platform/project/"+projectId+"/version/"+projectVersionId;

        //send request
        try {
            response = TB.apiResponse(requestURL, "GET");
        } catch (Exception e){
            Assert.fail("");
        }
        return response;
    }

    /*05.获取分组项目版本信息
    GET  https://bim.wanda.cn/platform/project/{projectId}/version/groupBy
    参数名         是否必选        类型      描述
    projectId   	是	           long	     项目ID*/
    public String getProjectVersionInfoByGroup(){
        //initial parameters
        requestURL = "/platform/project/"+projectId+"/version/groupBy";

        //send request
        try {
            response = TB.apiResponse(requestURL, "GET");
        } catch (Exception e){
            Assert.fail("");
        }
        return response;
    }

    /*06.创建项目
    POST  https://bim.wanda.cn/platform/project
    参数名         是否必选        类型      描述
    */
    public String createProject(){
        //initial parameters
        requestURL = "/platform/project";

        //send request
        try {
            response = TB.apiResponse(requestURL, "POST", requestBody);
        } catch (Exception e){
            Assert.fail("");
        }
        return response;
    }

    /*07.修改项目信息
    PUT  https://bim.wanda.cn/platform/project/{projectId}
    参数名         是否必选        类型      描述
    projectId   	是	           long	     项目ID*/
    public String modifyProjectInfo(){
        //initial parameters
        requestURL = "/platform/project/"+projectId;

        //send request
        try {
            response = TB.apiResponse(requestURL, "PUT", requestBody);
        } catch (Exception e){
            Assert.fail("");
        }
        return response;
    }

    /*08.获取指定项目信息
    GET  https://bim.wanda.cn/platform/project/{projectId}
    参数名         是否必选        类型      描述
    projectId   	是	           long	     项目ID*/
    public String getProjectInfo(){
        //initial parameters
        requestURL = "/platform/project/"+projectId;

        //send request
        try {
            response = TB.apiResponse(requestURL, "GET");
        } catch (Exception e){
            Assert.fail("");
        }
        return response;
    }

    //================================================================================
    //=====================================NO USE=====================================
    //================================================================================
    /*项目版本报审通过
    POST  https://bim.wanda.cn/platform/project/{projectId}/version/auditing/approve
    参数名         是否必选        类型      描述
    projectId   	是	           long	     项目ID*/
    public String approveProjectVersion(){
        //initial parameters
        requestURL = "/platform/project/"+projectId+"/version/auditing/approve";

        //send request
        try {
            response = TB.apiResponse(requestURL, "POST", requestBody);
        } catch (Exception e){
            Assert.fail("");
        }
        return response;
    }

    /*获取标准模型列表
    GET  https://bim.wanda.cn/platform/lib/standardModel
    参数名         是否必选        类型      描述
    */
    public String getStandardModelList(){
        //initial parameters
        requestURL = "/platform/lib/standardModel";

        //send request
        try {
            response = TB.apiResponse(requestURL, "GET");
        } catch (Exception e){
            Assert.fail("");
        }
        return response;
    }

    /*项目版本报审
    POST  https://bim.wanda.cn/platform/project/{projectId}/version/auditing
    参数名         是否必选        类型      描述
    projectId   	是	           long	     项目ID*/
    public String auditProjectVersion(){
        //initial parameters
        requestURL = "/platform/project/"+projectId+"/version/auditing";

        //send request
        try {
            response = TB.apiResponse(requestURL, "POST", requestBody);
        } catch (Exception e){
            Assert.fail("");
        }
        return response;
    }
}
